//
//  HXNavigationBar.m
//  navibarTest
//
//  Created by 周义进 on 14/09/2018.
//  Copyright © 2018 DaHuanXiong. All rights reserved.
//

#import "HXNavigationBar.h"
#import <objc/runtime.h>

@interface HXNavigationBar ()
@property (nonatomic, strong) NSHashTable   *navVCHT;

@property (nonatomic, strong) UIColor          *barTintColor;
@property (nonatomic, strong) UIColor          *tintColor;
@property (nonatomic, strong) UIColor          *titleColor;
@property (nonatomic, assign) UIStatusBarStyle  statusBarStyle;
@property (nonatomic, assign) BOOL              shadowImageHidden;

@property (nonatomic, assign) BOOL              blurEffectOpen;
@end


@implementation HXNavigationBar

#pragma mark - Life Cycle
+ (instancetype)sharedManager {
    
    static HXNavigationBar *manager;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[HXNavigationBar alloc] init];
        manager.shadowImageHidden = YES;
    });
    
    return manager;
}

#pragma mark - System Method

#pragma mark - Public Method

+ (void)hx_uesdToNavVCArr:(NSArray<UINavigationController *> *)navVCArr {
    for (id item in navVCArr) {
        [[HXNavigationBar sharedManager].navVCHT addObject:item];
    }
}

#pragma mark - setting

+ (void)hx_setNavigationBar_defaultBarTintColor:(UIColor *)barTintColor {
    [HXNavigationBar sharedManager].barTintColor = barTintColor;
}

+ (void)hx_setNavigationBar_defaultTintColor:(UIColor *)tintColor {
    [HXNavigationBar sharedManager].tintColor = tintColor;
}

+ (void)hx_setNavigationBar_defaultTitleColor:(UIColor *)titleColor {
    [HXNavigationBar sharedManager].titleColor = titleColor;
}

+ (void)hx_setStatusBar_defaultStyle:(UIStatusBarStyle)statusBarStyle {
    [HXNavigationBar sharedManager].statusBarStyle = statusBarStyle;
}

+ (void)hx_setNavigationBar_defaultShadowImageHidden:(BOOL)hidden {
    [HXNavigationBar sharedManager].shadowImageHidden = hidden;
}

+ (void)hx_setNavigationBar_defaultOpenBlurEffect:(BOOL)open {
    [HXNavigationBar sharedManager].blurEffectOpen = open;
}

#pragma mark -get
+ (UIColor *)hx_navigationBar_defaultBarTintColor {
    return [HXNavigationBar sharedManager].barTintColor ? [HXNavigationBar sharedManager].barTintColor : [UIColor whiteColor];
}

+ (UIColor *)hx_navigationBar_defaultTintColor {
    return [HXNavigationBar sharedManager].tintColor ? [HXNavigationBar sharedManager].tintColor : kHXTopicBlack;
}

+ (UIColor *)hx_navigationBar_defaultTitleColor {
    return [HXNavigationBar sharedManager].titleColor ? [HXNavigationBar sharedManager].titleColor : kHXTopicBlack;
}


+ (UIStatusBarStyle)hx_statusBar_defaultStyle {
    return [HXNavigationBar sharedManager].statusBarStyle;
}

+ (BOOL)hx_navigationBar_defaultShadowImageHidden {
    return [HXNavigationBar sharedManager].shadowImageHidden;
}

+ (BOOL)hx_navigationBar_defaultBlurEffectOpen {
    return [HXNavigationBar sharedManager].blurEffectOpen;
}

+ (BOOL)hx_canUsedInNavVC:(UINavigationController *)navVC {
    return [[HXNavigationBar sharedManager].navVCHT containsObject:navVC];
}


#pragma mark - Private Method

#pragma mark - Delegate

#pragma mark - Setter And Getter
- (NSHashTable *)navVCHT {
    if (!_navVCHT) {
        _navVCHT = [NSHashTable weakObjectsHashTable];
    }
    return _navVCHT;
}



#pragma mark - Dealloc






@end
